import bb.cascades 1.0

Page {
    
    titleBar: TitleBar {
        id: titleBar
        visibility: ChromeVisibility.Visible
        title: lang.setting_InitialAssets
    }
    
    Container {
        Container {
            horizontalAlignment: HorizontalAlignment.Center
            topPadding: 50
            
            Label {
                multiline: true
                text: lang.setting_IA_description
                
                textStyle{
                    textAlign: TextAlign.Center
                }
            }
        }
        Container {
            horizontalAlignment: HorizontalAlignment.Center
            topPadding: 20
            
            TextField {
                id: input_assets
                hintText: lang.setting_IA_hint
                inputMode: TextFieldInputMode.Pin
            }
        }
        Container {
            horizontalAlignment: HorizontalAlignment.Center
            topPadding: 50
                            
            Button {
                text: lang.next
                
                onClicked:{
                    var input = Number(input_assets.text);
                    console.log("assets number : " + input);
                    if (input != NaN && input != "" && input != undefined && input > 0){
                        var rt = database.Insert("t_bas_initialassets", {"famount": input, "fuserid": 0});
                        console.log("database rt : " + rt);
                        if (rt > 0){
                            var helpapage = helpa.createObject();
                            homeNavigation.push(helpapage);
                        }else{
                            root.showmsg(lang.error_database) ;
                        }
                    }else {
                        root.showmsg(error_input) ;
                    }
                }
            }
        }
    }
    
    attachedObjects: [
        ComponentDefinition {                      
            id: helpa                       
            source: "HelpA.qml"
        }
    ]
}
